package main.tcp;

import java.io.IOException;

public class EchoApp implements TcpApp {
	private TcpServer server;

	@Override
	public void setServer(TcpServer server) {
		this.server = server;
	}

	@Override
	public void setup() {

	}

	@Override
	public void onMsg(String address, String msg) {
		try {
			server.send(address, "echo:" + msg);
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}

	@Override
	public void onClose(String address) {
		try {
			server.broadcast("address:" + address + "quit.");
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
